home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #14
/
Monster Media No. 14 (April 1996) (Monster Media, Inc.).ISO
/
prog_d
/
cpltest.zip
/
CPLHEADR.PAS
next >
Wrap
Pascal/Delphi Source File
|
1996-01-10
|
5KB
|
156 lines
unit Cplheadr;
{*
** CREDITS:
** I had been strugling with converting my old C Control Panel
** Applications into DELPHI (No particular reason.. Just could it be
** done?) As a C-man I found DELPHI's documentation (rather lack
** thereof) not very helpful... so I turned to the man with the answers,
** Kurt Barthelmess of Team B. He pointed out my errors and boy did
** I feel 100% stupid. I've done PASCAL for 4 years and I felt like
** a 3 month cadet after Kurt pointed my obvious errors out to me.
** Looking past my ignorance, Kurt pointed me in the right direction.
** So, if you like this unit, remember to thank Kurt "The Man" Barthelmess.
**
** Also, in certain parts of this code I para-quote the CPL.INT
** file found in the DELPHI/DOC directory as pertaining to the
** CPL_xxx messages.
*}
{*
** Entered into the Public Domain by David A. Rigsby on January 10, 1996.
** Use this unit and Functions at your own risk. Feel free to modify and
** redistribute on the condition that any revisions keep this original
** header or in some way bears the name of the Author and those who may
** have modified and redistributed it. Always remember, Give Credit where
** Credit is due.... and you will feel SOOOOOOO Good about yourself..
** Ompa loompa dompa de do.....
**
** NOTE: Even though this is being entered into Public Domain, it may
** in no wise be copied or reproduced in a literary work,
** such as a Book, Video, Electronic Books, Code Sniplets,
** etc, without the express consent of the Author, David Rigsby,
** Who may be contacted via E-Mail at: BranhamTch@aol.com.
** Im a nice guy, just give me a chance......
**
** NOTE** And if there is anybody out there looking for contributors
** for Books, Videos, etc.. I'm your man. Just contact me
** via E-Mail at BranhamTch@aol.com and I will be more than happy
** to contribute my Hundreds of Code Samples and Sniplets that
** have taken over 6 years to compile. Here are some of the
** languages I am Proficient in:
**
** C DOS/Windows, C++ DOS/Windows, Pascal DOS, Pascal DELPHI,
** UNIX Kornshell, UNIX C, AS/400 RPG, and many more.
**
*}
interface
uses SysUtils,Forms,WinTypes,CPL;
{*
** Declare the CALLBACK (psuedo) for CPLApplet, the Control Panel will expect this.
** Remember, when you have integrated this unit into your application, in your
** Project source add the following line:
** EXPORTS
** CPLAPPLET;
**
*}
function CPLApplet (hWndCpl: HWnd; msg: Word;lParam1:LONGINT;var NewCPLInfo: TNEWCPLINFO): Longint;export;
implementation
{*
** For this project, my form dialog is called MainDlg. For the sake of reusability,
** I have made this CPL unit separate from my application. You can always take everything
** in this UNIT and PASTE it into your Main Unit. That would be cool. Right now, I have
** This unit setup as a Template which I add to my projects and simply modify a
** couple of Parameters.
*}
uses Maindlg;
function CPLApplet (hWndCpl: HWnd; msg: Word;lParam1:LONGINT;var NewCPLInfo: TNEWCPLINFO): Longint;
begin
case msg of
CPL_INIT:
begin
{*
** This message is sent to indicate CPlApplet() was found.
** Return TRUE or FALSE indicating whether the control panel should proceed.
*}
CPlApplet:=1;
end;
CPL_GETCOUNT:
{*
** How many applets do you wish?
** If this is greater than 1, the Control Panel will
** send the CPL_NEWINQUIRE message for that many applications.
** EX: If you return 3, CPL_NEWINQUIRE will be sent to you 3
** times. Each time control panel will be expecting information
** as pertaining to each of the Three Applets to be displayed.
** For this example, we'll just do one.
*}
CPlApplet:=1;
CPL_NEWINQUIRE:
begin
{*
** This was the bear. This is majorly what Kurt helped me with.
** I couldn't seem to get the function prototype correct enough
** to get this code to compile much less work correctly.
*}
with NewCPLInfo do
begin
{*
** Like good boys and girls, we must initialize the SIZE of our
** Structure so windows won't choke on us!
*}
dwSize:=sizeof(TNEWCPLINFO);
dwFlags := 0;
dwHelpContext := 0;
lData := 0;
{*
** I rarlely modify this. I usually associate an ICON with my
** DLL and just reference it this way. (Options | Project | Application)
*}
Icon :=Application.Icon.Handle;
szHelpFile[0]:= #0;
{*
** This displays a Short Description in the Control Panel's Window
*}
StrPCopy(szName,'DEPLHI Applet');
{*
** This displays a Long Description in the Control Panel's Status Bar.
*}
StrPCopy(szInfo,'Wonderful Control Panel Test. Double click and see the magic!');
end;
end;
CPL_DBLCLK:
{*
** The user Double Clicked and wants to activate us.
** Create the Form and Show it MODAL!
*}
begin
MainForm:=TMainForm.Create(Application);
MainForm.ShowModal;
end;
{*
** There are more messages like CPL_STOP and CPL_DBLCLK, but we won't respond to
** them. Feel Free to do so if you want to.
*}
{
CPL_STOP:;
CPL_EXIT:;
}
end;
end;
end.